function validateFormBeforeSubmitForAddProject(theForm){
	var reason = "";
	var projectCode = validateMe(document.getElementById('projectCode'),'Project Code');
	reason += projectCode;
	var projectTitle = validateMe(document.getElementById('projectTitle'),'Project Title');
	reason += projectTitle;
	var startDateCalender = validateMe(document.getElementById('startDateCalender'),'Start Date');
	reason += startDateCalender;
	
	if (reason != "") {
		 alert("Errors:\n" + reason); 
		return false;
	} 
	document.forms["addProject"].action = "projectMaintenance.html?method=saveProject";
	document.forms.addProject.submit();
}

function validateMe(fld,name) { 
	var error = "";

	if (fld.value == null || (fld.value != null && fld.value.length == 0) ) {
		fld.style.background = 'Yellow'; 
		error = name+" field has not been filled in.\n"
	} else {
		var numaric = fld.value;
		for(var j=0;j < numaric.length ; j++)
		{
			if(j==0){
			var alphaa = numaric.charAt(j);
			var chCode = alphaa.charCodeAt(0);
			if(chCode == "32"){
				fld.style.background = 'Yellow'; 
				error = name+" should not start with space.\n"
			}
			}
		}
		fld.style.background = 'White';
	}
	return error;  
	}